package com.xueyi.aixihu.pattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 刘梓江
 */
public class FinanceReportStateStrategyDirector {

    private static final FinanceReportWaitSubmitStateStrategy waitSubmit=FinanceReportWaitSubmitStateStrategy.getInstance();
    private static final FinanceReportUnderAuditStateStrategy underAudit=FinanceReportUnderAuditStateStrategy.getInstance();
    private static final FinanceReportAuditPassedStateStrategy auditPassed=FinanceReportAuditPassedStateStrategy.getInstance();
    private static final FinanceReportPublicStateStrategy publicState=FinanceReportPublicStateStrategy.getInstance();

    private List<FinanceReportStateStrategy> stateStrategies=new ArrayList<>();
    {
        //封装策略对象信息
        stateStrategies.add(waitSubmit);
        stateStrategies.add(underAudit);
        stateStrategies.add(auditPassed);
        stateStrategies.add(publicState);
    }

    //获取相应状态对应的策略对象
    public FinanceReportStateStrategy getStateStrategy(String state){
        for (FinanceReportStateStrategy stateStrategy : stateStrategies) {
            if(stateStrategy.support(state)){
                return stateStrategy;
            }
        }
        return null;
    }

    public FinanceReportStateStrategy getFinanceReportWaitSubmitStateStrategy(){
        return waitSubmit;
    }

    public FinanceReportStateStrategy getFinanceReportUnderAuditStateStrategy(){
        return underAudit;
    }

    public FinanceReportStateStrategy getFinanceReportAuditPassedStateStrategy(){
        return auditPassed;
    }

    public FinanceReportStateStrategy getFinanceReportPublicStateStrategy(){
        return publicState;
    }


}
